<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/page/common/taglibs.jsp" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
考试名：${exam.examName}<br/>
考试时间： ${exam.startTimeShow} —— ${exam.endTimeShow}
<input type="hidden" name="id" value="${examId}"/>
<table cellspacing="0" cellpadding="10" border="1px" align="center" >
    <tr>
        <th>编号</th>
        <th>姓名</th>
        <th>操作</th>
    </tr>
    <tbody id="td">

    </tbody>
</table>
</body>
<script type="text/javascript">
    $(function(){
        search();
    });
    
    function search(){
        $.post(
            "${ctx}/exam/userList",
            {"examId":${examId}},
            function (result){
                html = "";
                for (let i = 0; i < result.data.length; i++) {
                    var u = result.data[i];
                    html +="<tr>";
                    html +="<td>"+u.id+"</td>";
                    html +="<td>"+u.userName+"</td>";
                    html +="<td>";
                    html +="<input type='button' value='移除' onclick='yi("+u.id+")'/>";
                    html +="</td>";
                    html +="</tr>";
                }
                $("#td").html(html);
            }
        );
    }

    function yi(id){
        layer.confirm('您确定要移除吗', function(index){
            var index = layer.load(1);
            $.post(
                "${ctx}/exam/del/"+id,
                {},
                function(result){
                    layer.close(index);
                    if(result.code == "200"){
                        parent.location.href = "${ctx}/exam/toShow";
                    } else {
                        layer.msg(result.msg,{icon:0.5});
                        return;
                    }
                }
            );
        });
    }

</script>
</html>
